<template>
	<view>
		<view class="perInfo alignCen">
			<view class="perImg defBg">
				<image class="samePar" :src="getUrl(perInfo.portrait == undefined ? perInfo.portait : perInfo.portrait)"></image>
			</view>
			<view class="perInfoCon">
				<view class="userName hasFlex">
					<view>{{perInfo.realName}}</view>
					<view class="gradeName" @tap.stop="switchGrade">
						<text>{{gradeName}}</text>
						<text class="iconfont icon-switch"></text>
					</view>
				</view>
				<view class="bot spaceBet">
					<view class="rank hasFlex">
						<text class="iconfont icon-huiyuanvip"></text>
						<text style="font-weight: bold;">{{perInfo.userLevel == undefined ? perInfo.level : perInfo.userLevel}}级</text>
						<view class="lineView"></view>
						<text>{{perInfo.userLevelName == undefined ? perInfo.levelName : perInfo.userLevelName}}</text>
						<view class="lineView"></view>
						<text>{{perInfo.coin}}积分</text>
					</view> 
				</view>
				<template v-if="currPage == 'indexPage'">
					<view class="iconfont icon-gengduo"></view>
				</template>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			perInfo:Object,
			gradeName:String,
			currPage:String,
			currStateNum:Number,
			overDateNum:Number
		},
		computed:{
			classes(){
				return function(currStateNum){
					return{
						'overDate': currStateNum == 0,
						'nearOverDate' : currStateNum == 1,
						'normal' : currStateNum == 2
					}
				}
			},
			getUrl(){
				return function(url){
					if(url != undefined){
						if(url.startsWith( 'Module' )){
							return this.zhuXueServer + '/' + url
						}else{
							return url;
						}
					}
				}
			}
		},
		methods:{
			switchGrade(){
				this.$emit('switchGrade');
			}
		}
	}
</script>

<style lang="scss" scoped>
	.perInfoCon{
		flex: 1;
		height: 120rpx;
		position: relative;
		// .endDate{
		// 	position: absolute;
		// 	padding: 0 15rpx;
		// 	border-radius: 0 15rpx 0 15rpx;
		// 	box-shadow: 0 0 15rpx rgba(0,0,0,.1);
		// 	@include respTo(phone){
		// 		height: 50rpx;
		// 		line-height: 50rpx;
		// 		right: -20rpx;
		// 		top: -20rpx;
		// 		font-size:$font-size26;
		// 	}
		// 	@include respTo(pad){
		// 		height: 36rpx;
		// 		line-height: 36rpx;
		// 		right: -10rpx;
		// 		top: -10rpx;
		// 		font-size:$padSize14;
		// 	}
		// 	.normal{
		// 		color: $pss-color-green-deep;
		// 	}
		// 	.nearOverDate{
		// 		color: $pss-color-primary_2;
		// 	}
		// 	.overDate{
		// 		color: $pss-color-red;
		// 	}
		// 	.icon-yiwen{
		// 		margin-left: 10rpx;
		// 		color: $pss-text-colora;
		// 		@include respTo(phone){
		// 			font-size:$font-size28;
		// 		}
		// 		@include respTo(pad){
		// 			font-size:$padSize16;
		// 		}
		// 	}
		// }
		.icon-gengduo{
			position: absolute;
			right: 20rpx;
			top: 50rpx;
			@include respTo(phone){
				font-size: $font-size28;
			}
			@include respTo(pad){
				font-size: $padSize16;
			}
			color: $pss-text-colora;
		}
		.rank{
			padding: 0 20rpx;
			border-radius: 50rpx;
			background: $pss-color-primary_2;
			color: #fff;
			@include respTo(phone){
				height: 52rpx;
				line-height: 52rpx;
				font-size:$font-size28;
			}
			@include respTo(pad){
				height: 38rpx;
				line-height: 38rpx;
				font-size:$padSize16;
			}
			.icon-huiyuanvip{
				margin-right: 5rpx;
				@include respTo(phone){
					font-size:$font-size28;
				}
				@include respTo(pad){
					font-size:$padSize20;
				}
			}
			.lineView{
				background: #fff;
				border-radius: 20rpx;
				opacity: .6;
				@include respTo(phone){
					width: 5rpx;
					height: 22rpx;
					margin: 18rpx 15rpx 0;
				}
				@include respTo(pad){
					width: 4rpx;
					height: 16rpx;
					margin: 12rpx 15rpx 0;
				}
			}
		}
		.userName{
			color: $pss-text-color3;
			font-weight: bold;
			align-items: center;
			@include respTo(phone){
				font-size: $font-size32;
				margin-bottom: 15rpx;
			}
			@include respTo(pad){
				font-size: $padSize26;
				margin:15rpx 0 15rpx 0;
			}
			.gradeName{
				margin-left: 15rpx;
				color: $pss-text-color8;
				font-weight: normal;
				@include respTo(phone){
					font-size: $font-size28;
				}
				@include respTo(pad){
					font-size: $padSize20;
				}
				.icon-switch{
					@include respTo(phone){
						font-size: $font-size30;
					}
					@include respTo(pad){
						font-size: $padSize20;
					}
				}
			}
		}
	}
	.perImg{
		border-radius: 50%;
		margin-right: 20rpx;
		flex-shrink: 0;
		@include respTo(phone){
			width: 120rpx;
			height: 120rpx;
		}
		@include respTo(pad){
			width: 100rpx;
			height: 100rpx;
		}
		.samePar{
			border-radius: 50%;
		}
	}
</style>